/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   mem_leak.h
 * Author: dou
 *
 * Created on 2016年2月25日, 下午4:04
 */

#ifndef MEM_LEAK_H
#define MEM_LEAK_H

#ifdef __cplusplus
extern "C" {
#endif

#include "ooc_typedef.h"    
#include "clist.h"

    //使用log文件的配置开关
#define MLEAK_CFG_USE_LOG_FILE              MOFF

#define MLEAK_FILE_NAME_LEN_BYTE_MAX        64

#define MLEAK_LOG_FILE_NAME                 "./mem_leak_log.txt"

    
    typedef enum{
        MLEAK_REPORT_LEVEL_BRIEF,
        MLEAK_REPORT_LEVEL_REMAIN,
        MLEAK_REPORT_LEVEL_FULL,
    }MLeakReportLevelDef;
    
    
    typedef struct {
        CListDef* pRemaining; //剩下的未释放内存
        CListDef* pFreed; //已释放的内存
    } MLeakDef;    
    
    mbool MLeak_Init(MLeakDef* cthis);
    void* MLeak_Malloc(MLeakDef* cthis, size_t nSize, muc8* sFileName, mu32 nLineNum);
    void MLeak_Free(MLeakDef* cthis, void* pMem);
    void MLeak_ShowReport(MLeakDef* cthis, MLeakReportLevelDef eLevel);

#ifdef __cplusplus
}
#endif

#endif /* MEM_LEAK_H */

